package simulacao;

// AgenteBot

// Java AgentBot.
// Autor: Alexandre Heideker - alexandre.heideker@ufabc.edu.br
// UFABC Jun/2009
//

import swarm.Globals;
import swarm.objectbase.Swarm;
import swarm.objectbase.SwarmImpl;
import swarm.simtoolsgui.GUISwarm;
import swarm.simtoolsgui.GUISwarmImpl;

public class StartBot
{

    public static int saidaX, saidaY;

public static void main (String[] args)
{
    saidaX=-1;
    saidaY=-1;

    Globals.env.initSwarm
     ("AgentBot", "2.1", "alexandre.heideker@ufabc.edu.br", args);
    BotModelSwarm model;
   
    if (Globals.env.guiFlag)
    {
        BotObserverSwarm topLevelSwarm
         = new BotObserverSwarm (Globals.env.globalZone);
        Globals.env.setWindowGeometryRecordName (topLevelSwarm, "topLevelSwarm");
        model = topLevelSwarm.getBotModelSwarm ();
        build (topLevelSwarm, model);
        topLevelSwarm.go ();
        unbuild (topLevelSwarm, model);
    }
} /// main()

private static void build (Swarm swarm, BotModelSwarm model)
{
    model.setNumBots (getIntProperty ("n", -1));
    swarm.buildObjects ();
    swarm.buildActions ();
    swarm.activateIn (null);
} /// build()

private static void unbuild (Swarm swarm, BotModelSwarm model)
{
    swarm.drop ();
}

private static boolean getBooleanProperty (String propertyName, boolean dflt)
{
    String property = System.getProperty (propertyName);
    if (property == null || property.equals ("")) return dflt;
    else return property.equals ("true") || property.equals ("1");
}
private static double getDoubleProperty (String propertyName, double dflt)
{
    String property = System.getProperty (propertyName);
    if (property == null || property.equals ("")) return dflt;
    else return Double.parseDouble (property);
}
private static int getIntProperty (String propertyName, int dflt)
{
    String property = System.getProperty (propertyName);
    if (property == null || property.equals ("")) return dflt;
    else return Integer.parseInt (property);
}
private static String getStringProperty (String propertyName, String dflt)
{
    String property = System.getProperty (propertyName);
    if (property == null) return dflt;
    return property;
}

}
